const initialState = {
  channels: [], // 频道列表
  // 文章列表
  list: [], // 文章列表
  total: 0, // 查询条件文章总数
};

export const article = (state = initialState, action) => {
  // 获取频道列表
  if (action.type === 'article/getChannels') {
    return {
      ...state,
      channels: action.payload,
    };
  }

  if (action.type === 'article/getArticles') {
    return {
      ...state,
      list: action.payload.list,
      total: action.payload.total,
    };
  }

  return state;
};
